import useRequest from '@/utils/request'

const request = useRequest({})

// 登录方法
export function login(
  username: string,
  password: string,
  code: string,
  uuid: string,
  mobileCode: string,
) {
  return request.post(
    '/auth/login',
    { username, password, code, uuid, mobileCode },
    {
      headers: {
        isToken: false,
      },
    },
  )
}

// 注册方法
export function register(data: any) {
  return request.post('/auth/register', data, {
    headers: {
      isToken: false,
    },
  })
}

// 刷新方法
export function refreshToken() {
  return request.post('/auth/refresh')
}

// 登录-获取手机号
export function getMobile(params: Record<string, any>) {
  return request.get(`/auth/getMobile`, { params })
}

// 获取用户详细信息
export function getInfo(params: any = {}) {
  return request.get('/system/user/getInfo', {
    params,
  })
}

// 退出方法
export function logout() {
  return request.delete('/auth/logout')
}

// 获取验证码
export function getCodeImg() {
  return request.get('/code', {
    headers: {
      isToken: false,
    },
    timeout: 20000,
  })
}

//注册-获取验证码
export function sendLoginNoByPhone(params: Record<string, any>) {
  return request.get(`/system/user/open/sendLoginNoByPhone`, { params })
}

//注册-确认验证码
export function checkPhone(params: Record<string, any>) {
  return request.get(`/system/user/open/checkPhone`, { params })
}

//注册-确认注册
export function registerPcUser(data: any) {
  return request.post(`/system/user/open/registerPcUser`, data)
}

//登录-获取手机验证码
export function sendLoginNoByName(params: Record<string, any>) {
  return request.get(`/system/user/open/sendLoginNoByName`, { params })
}
